window.operateEvents={
    "click .tableCheck":function (e,value,row,index) {
        var a=getParaKey(row.accessPointId);
        var b=getSignKey(row.accessPointId);
        $('#secretKeyModal').modal('show');
    }
}
function operateFormatter(value, row, index) {
    return [
        '<a class="tableCheck ml10" style="color:black;" href="javascript:void(0)" title="查询密钥">',
        '<button  type="button" class="btn btn-primary">查询密钥</button>',
        '</a>&emsp;'
    ].join('');
}

function showButton(value,row,index) {
    if(row.enableState==1){
        return "<span type='text' class='btn btn-primary btn-sm'>已启用</span>";
    }else{
        return "<span type='text' class='btn btn-primary btn-sm'>已禁用</span>";
    }
}
function getSignKey(accessPointId) {
    $.ajax(
        {
            url: "secretkey/sign/get",
            data: {"accessPointId": accessPointId},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.code==1000) {
                    var md5Key=data.data.md5Key;
                    $('#signSecretKey').val(md5Key);

                }
                if(data.code==1081){
                    var result="签名密钥不存在";
                    $('#signSecretKey').val(result);
                }
            },
            error: function () {
                alert('请求出错');
            }
        });
}

function getParaKey(accessPointId) {
    $.ajax(
        {
            url: "secretkey/para/get",
            data: {"accessPointId": accessPointId},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.aesKey!=null) {
                    $('#paraSecretKey').val(data.aesKey);
                    $('#paraSecretIv').val(data.aesIv);
                    return null;
                }
                if (data.code==1082) {
                    $('#paraSecretKey').val("参数密钥不存在");
                    $('#paraSecretIv').val("参数密钥不存在");
                    return null;
                }
                alert('操作失败');

            },
            error: function () {
                alert('请求出错');
            }
        });
}
$('#refreshbutton').click(function () {
    location.reload();
});
$('#secretKeyModal').on('hide.bs.modal', function () {
    $('#paraSecretKey').val("");
    $('#paraSecretIv').val("");
    $('#signSecretKey').val("");
    location.reload();
})
